FROM swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:24.03-lts

# os基础版本如下：
# sudo yum install docker
# docker pull swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:22.03-lts
# https://www.openeuler.org/zh/download/archive/detail/?version=openEuler%2022.03%20LTS%20SP4

LABEL maintainer="lifubing@agiros"

# 切换到 root 用户（默认就是 root，这一步可以省略）
USER root

ARG USERNAME=agiros_24.03
ARG USER_UID=1000
ARG USER_GID=$USER_UID

ENV ROS_OS_OVERRIDE centos
ENV MYPATH /home/$USER/euler_ros
WORKDIR $MYPATH

# step0 挂载宿主机/data目录到容器 =============================================
VOLUME /data

# step1 安装必要的软件 =======================================================

#RUN yum clean all && yum makecache 
RUN yum -y update
#方便使用docker容器
RUN yum install -y python3-pip vim iputils net-tools wget
# colcon需要
RUN yum -y install gcc automake autoconf libtool make
# step2 安装编译器colcon =======================================================
RUN pip install colcon-common-extensions colcon-mixin
RUN colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml

# step3 安装rosdep ============================================================
RUN pip3 install rosdep
RUN rosdep init

# step4 安装Agiros，配置环境 ===================================================
# 禁用其他软件源（干净系统跳过此步骤）
RUN cd /etc/yum.repos.d
# 若之前安装过欧拉系统的ROS软件，需要先移除ROS源
# RUN mv openEulerROS.repo openEulerROS.repo.bak
# 添加AGIROS软件源文件
RUN wget -O /etc/yum.repos.d/agiros.repo http://1.94.193.239/yumrepo/agiros/openeuler2203sp2/agiros.repo
# 此时容器本地/etc/yum.repo.d/目录下会生成一个agiros.repo文件

RUN if [ -e /etc/yum.repos.d/openEuler.repo ]; then mv /etc/yum.repos.d/openEuler.repo /etc/yum.repos.d/openEuler.repo.bak; else echo "新下载openEuler.repo文件"; fi
# 官网的repo可能是错的
RUN wget -O /etc/yum.repos.d/openEuler.repo http://1.94.193.239/yumrepo/agiros/openeuler2203sp2/openEuler.repo

# 安装Agiros-loong-0.1.0
RUN yum -y install agiros-loong-agiros-base agiros-loong-turtlesim

# 配置环境变量 
RUN touch /etc/profile.d/agiros.sh
RUN echo " source /opt/agiros/loong/setup.bash" >> /etc/profile.d/agiros.sh
RUN chmod +x /etc/profile.d/agiros.sh

RUN pip cache purge
RUN yum clean all